<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    //Date
   // let now=new Date();
    //console.log()直接打印对象的时候，会自动调用对象的toString()方法
    /*console.log(now);
    console.log(now.toString());
    console.log(now.toLocaleString())*/
    /*
    //获取当前年份
    console.log(now.getFullYear())
    //获取当前月份，获取月份是从0开始的
    console.log(now.getMonth()+1)
    //获取天数
    console.log(now.getDate());
    //获取小时
    console.now(now.getHours())
    //获取分钟
    console.log(now.getMinutes());
    //获取秒
    console.log(now.getSeconds());

     */
    //拼接年月日时分秒
    let now=new Date();

    //三元表达式
    let month=(now.getMonth()+1)<10 ? '0'+(now.getMonth()+1):(now.getMonth()+1)
    let p=now.getFullYear()+'年'+(now.getMonth()+1)+'月'
    +now.getDate()+"日"+" "+now.getHours()+"时";

</script>
</body>
</html>